package com.itheima.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.SysLog;
import com.itheima.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * ClassName:SysLogController
 * Package:com.itheima.controller
 * Description:
 * Date:2020/3/14 16:29
 * User: snow
 */
@Controller
@RequestMapping("/sysLog")
public class SysLogController {
	@Autowired
	private SysLogService sysLogService;

	@RequestMapping("/findAll.do")
	public ModelAndView findAll
			(@RequestParam(name = "page",required = true,defaultValue = "1")Integer page,
	                            @RequestParam(name = "size", required = true,defaultValue = "15")Integer size) throws Exception {
		ModelAndView view = new ModelAndView();
		List<SysLog> sysLogs = sysLogService.findAll(page,size);
		PageInfo pageInfo = new PageInfo(sysLogs);
		view.addObject("pageInfo",pageInfo);
		view.setViewName("syslog-list");
		return view;
	}
}
